package com.showde.shoppingmall.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.showde.shoppingmall.db.constant.AddressConstant;
import com.showde.shoppingmall.db.constant.BillConstant;
import com.showde.shoppingmall.db.constant.ProductAHRConstant;
import com.showde.shoppingmall.db.constant.ProductCategoryConstant;
import com.showde.shoppingmall.db.constant.ProductCollectionConstant;
import com.showde.shoppingmall.db.constant.ProductConstant;
import com.showde.shoppingmall.db.constant.ProductDescConstant;
import com.showde.shoppingmall.db.constant.ProductInBillConstant;
import com.showde.shoppingmall.db.constant.ShoppingCartConstant;
import com.showde.shoppingmall.db.constant.UserConstant;

public class DBHelper extends SQLiteOpenHelper {

	private static final String DB_NAME = "sm.db"; // 数据库名称
	private static final int DB_VERSION = 1; // 数据库版本

	public DBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	/*
	 * public DBHelper(Context context, DatabaseErrorHandler errorHandler) {
	 * super(context, DB_NAME, null, DB_VERSION, errorHandler); }
	 */

	@Override
	public void onCreate(SQLiteDatabase db) {
		initDB(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

	private void initDB(SQLiteDatabase db) {
		db.execSQL(UserConstant.SQL_CREAT);
		db.execSQL(AddressConstant.SQL_CREAT);
		db.execSQL(BillConstant.SQL_CREAT);
		db.execSQL(ProductCategoryConstant.SQL_CREAT);
		db.execSQL(ProductConstant.SQL_CREAT);
		db.execSQL(ProductAHRConstant.SQL_CREAT);
		db.execSQL(ProductInBillConstant.SQL_CREAT);
		db.execSQL(ProductDescConstant.SQL_CREAT);
		db.execSQL(ShoppingCartConstant.SQL_CREAT);
		db.execSQL(ProductCollectionConstant.SQL_CREATE);
	}

}
